/* ************************************************************************** */
/*Enterprise edition 2011: Modified for EE 2011                               */
/*xxpclsmt_e.p - Renamed to use for korea sites and FJC (CR02)             */
/*xxpclsmt.p - Renamed to use for korea sites and FJC (CR02)             */
/*kxpclsmt.p - Renamed to use for both korea sites(HD0000002348140)      */
/*k1pclsmt.p - Price List Maintenance and Report                         */
/*COPYRIGHT JCI. INC ALL RIGHTS RESERVED. THIS IS AN UNPUBLISHED WORK.   */
/*V8:ConvertMode=Report                                                  */
/*V8:WebEnabled=No                                                       */
/*V8:RunMode=Character,Windows                                           */
/*Program to store buyer who is responsible for change in price list.    */
/*And also changed price list Report                                 */
/*************************************************************************/
/* PROCEDURE NAME           : k1pclsmt.p                                 */
/* PROCEDURE TYPE           : Process                                    */
/* DESCRIPTION              :                                            */
/* INCLUDE FILES            :                                            */
/* CALLED BY                :                                            */
/* CALLED PROCEDURES        :                                            */
/*************************************************************************/
/* CREATED BY           : Madhura Joshi(TCSL)   DATE: 27/03/06       */
/*MODIFIED BY               : Madhura Joshi(TCSL) ECO#MJ120506  12/05/06 */
/*                            Pop-up frame was not coming some time      */
/*MODIFIED BY               : Madhura Joshi(TCSL) ECO#MJ260506  26/05/06 */
/*                            To remove TAB key trigger setting          */
/*MODIFIED BY               : Madhura J(TCSL) #HD0000002348140  01/02/08 */
/*                            To add 1 more field in pc_user1            */
/*MODIFIED BY               : Gomichan (TCSL) #HD0000002525732  27/05/08 */
/*MODIFIED BY               : Madhura J(TCSL) #MJCR02 SRR0135-CR02 28/05/09 */
/*MODIFIED BY               : Anurag Joshi(TCSL) #HD0000003495329 28/05/09 */
/* *********************************************************************** */
/*ADNT-NBR:262713 DATE:06/22/22   ECO:DJ01 MODIFIED BY:Deepti Jain (TCS)     */
/*FS/SRR:NA SR:SCTASK0501548	  Uplift to CFAA 2019                        */
/*****************************************************************************/


{us/bbi/mfdeclre.i} /*DJ01*/
{us/bbi/gplabel.i} /*DJ*/
{us/wb/wbrp01.i}   /*DJ01*/ /* desktop */

/* Variable Defination */
DEFINE NEW SHARED VARIABLE m_list      like pc_list        NO-UNDO.
DEFINE NEW SHARED VARIABLE m_ran       as character format "x(12)" NO-UNDO.
DEFINE NEW SHARED VARIABLE m_eono      as character format "x(12)" NO-UNDO.
DEFINE NEW SHARED VARIABLE m_champid   AS character format "x(30)" NO-UNDO.
DEFINE NEW SHARED VARIABLE m_reason    AS CHARACTER format "x(40)" no-undo.
/* *****HD0000002348140 START***** */
DEFINE NEW SHARED VARIABLE m_custduty  AS decimal format "->>,>>>,>>9.99" no-undo.
/* *****HD0000002348140 END***** */
DEFINE NEW SHARED VARIABLE m_netprice  AS DECIMAL FORMAT "->>,>>>,>>9.99" NO-UNDO. /* HD0000002525732 */

DEFINE        VARIABLE m_remark    AS character format "x(50)" NO-UNDO.
DEFINE        VARIABLE m_curr      LIKE pc_curr        NO-UNDO.
DEFINE        VARIABLE m_prod_line LIKE pc_prod_line       NO-UNDO.
DEFINE        VARIABLE m_part      LIKE pc_part        NO-UNDO.
DEFINE        VARIABLE m_um        LIKE pc_um          NO-UNDO.
DEFINE        VARIABLE m_start     LIKE pc_start           NO-UNDO.
DEFINE        VARIABLE m_flag      as   logical        NO-UNDO.
DEFINE        VARIABLE m_arg1      as   CHARACTER          NO-UNDO.

define buffer pcmstr for pc_mstr.

/* Form Defination */
FORM
  m_ran     colon 20
  m_eono    colon 20
  m_champid colon 20
  m_reason  colon 20
  m_remark  colon 20
/* HD0000002348140 */  m_custduty colon 20
  m_netprice  colon 20  /* HD0000002525732 */
WITH FRAME frm1 SIDE-LABELS width 75 overlay row 10 col 5.
setframelabels(frame frm1:handle).

/*One of the Functions used to get field value of frame */
FUNCTION GetTopParent RETURNS HANDLE (INPUT piParentHandle AS HANDLE):

DEFINE VARIABLE poTopParent AS HANDLE NO-UNDO.

IF VALID-HANDLE(piParentHandle) THEN
DO:
  IF piParentHandle:TYPE = "WINDOW" THEN
  DO:
    ASSIGN poTopParent = piParentHandle.
    RETURN poTopParent.
  END.
  ELSE DO:
    ASSIGN piParentHandle = piParentHandle:PARENT.
    poTopParent = GetTopParent (piParentHandle).
    IF VALID-HANDLE(poTopParent) THEN
      RETURN poTopParent.
    ELSE
      RETURN ?.
  END. /* ELSE DO */
END. /* IF VALID-HANDLE */
END FUNCTION.


ON ENDKEY, PF4, F4, end-error  ANYWHERE DO:
   ASSIGN m_flag = NO.
   return.
END. /* ON ENDKEY */



/* Trigger on GO,RETURN AND TAB */
/* MJ260506 ON GO,TAB,RETURN ANYWHERE DO: */

/* MJ260506 */ ON GO,RETURN ANYWHERE DO:
   if frame-field = 'pc_list' then do:
      m_list = frame-value.
   end.

/* MJCR02 START */
   IF FRAME-NAME = "a" and KEYFUNCTION(LASTKEY) = "GO" and
      (frame-field = 'pc_list' or frame-field = 'pc_curr' or
       frame-field = 'pc_prod_line' or frame-field = 'pc_part' or
       frame-field = 'pc_um' or frame-field = 'pc_start') and m_flag = no then do:
      IF CAN-FIND(FIRST code_mstr WHERE code_domain = global_domain and
                                        code_fldname BEGINS "xxpriceprefix") THEN DO:
         FOR FIRST emp_mstr WHERE emp_domain = global_domain and
                                  emp_addr = global_userid NO-LOCK: END.
         IF AVAILABLE emp_mstr THEN DO:
            FOR FIRST code_mstr WHERE code_domain = global_domain and
                                      code_fldname BEGINS "xxpriceprefix"
                                 AND LOOKUP (emp_title,code_cmmt) > 0
                                 NO-LOCK: END.
            IF NOT AVAILABLE code_mstr THEN DO:
               m_arg1 = " " + getTermLabel("PRICE_LIST",11).
               /* 3920 User does not have access to this # */
               {us/bbi/pxmsg.i &msgnum=3920 &errorlevel=3 &msgarg1=m_arg1}  /*DJ01*/
               RETURN NO-APPLY.
            END. /* IF NOT AVAILABLE code_mstr THEN */
            FOR FIRST code_mstr WHERE code_domain = global_domain and
                                      code_fldname BEGINS "xxpriceprefix"
                                 AND m_list BEGINS code_value
                                 NO-LOCK: END.
            IF NOT AVAILABLE code_mstr THEN DO:
               m_arg1 = getTermLabel("PRICE_LIST",11) + " " + getTermLabel("PREFIX",7).
               /* 9610 GCM is not defined for # */
               {us/bbi/pxmsg.i &msgnum=9610 &errorlevel=3 &msgarg1=m_arg1} /*DJ01*/
               RETURN NO-APPLY.
            END. /* IF NOT AVAILABLE code_mstr THEN */
            FOR FIRST code_mstr WHERE code_domain = global_domain and
                                      code_fldname BEGINS "xxpriceprefix"
                                 AND m_list BEGINS code_value
                                 AND LOOKUP (emp_title,code_cmmt) > 0
                                 NO-LOCK: END.
            IF NOT AVAILABLE code_mstr THEN DO:
               m_arg1 = " " + getTermLabel("PRICE_LIST",11).
               /* 3920 User does not have access to this # */
               {us/bbi/pxmsg.i &msgnum=3920 &errorlevel=3 &msgarg1=m_arg1} /*DJ01*/
               RETURN NO-APPLY.
            END. /* IF NOT AVAILABLE code_mstr THEN */

         END. /* IF AVAILABLE emp_mstr THEN */
         ELSE DO:
            m_arg1 = " " + getTermLabel("PRICE_LIST",11).
            /* 3920 User does not have access to this # */
            {us/bbi/pxmsg.i &msgnum=3920 &errorlevel=3 &msgarg1=m_arg1} /*DJ01*/
            RETURN NO-APPLY.
         END. /* IF NOT AVAILABLE emp_mstr THEN */
      END. /* IF CAN-FIND(FIRST code_mstr */
   END. /* IF FRAME-NAME = "a" and KEYFUNCTION(LASTKEY) = "GO" */
/* MJCR02 END */

   IF FRAME-NAME = "a" and KEYFUNCTION(LASTKEY) = "GO" and
      (frame-field = 'pc_expire' or frame-field = 'pc_amt_type') and m_flag = no then do:
      clear frame frm1 all.
      hide frame frm1.

      /* To get value to fields */
      RUN GetFieldValue IN THIS-PROCEDURE
      (INPUT "pc_curr", INPUT "a", OUTPUT m_curr).
      RUN GetFieldValue IN THIS-PROCEDURE
      (INPUT "pc_prod_line", INPUT "a", OUTPUT m_prod_line).
       RUN GetFieldValue IN THIS-PROCEDURE
      (INPUT "pc_part", INPUT "a", OUTPUT m_part).
       RUN GetFieldValue IN THIS-PROCEDURE
      (INPUT "pc_um", INPUT "a", OUTPUT m_um).
       RUN GetFieldValue IN THIS-PROCEDURE
      (INPUT "pc_start", INPUT "a", OUTPUT m_start).

      /* Initialise variables */
      find first pcmstr where pcmstr.pc_domain = global_domain and
                              pcmstr.pc_list = m_list and
                      pcmstr.pc_curr = m_curr and
                  pcmstr.pc_prod_line = m_prod_line and
                  pcmstr.pc_part = m_part and
                  pcmstr.pc_um = m_um and
                  pcmstr.pc_start = m_start no-lock no-error.
      if available pcmstr then do:
         assign m_ran = substring(pcmstr.pc_user1,1,12, "RAW")      /* HD0000003495329 Added "RAW" */
            m_eono = substring(pcmstr.pc_user1,13,12, "RAW")        /* HD0000003495329 Added "RAW" */
        m_champid = substring(pcmstr.pc_user1,25,12, "RAW")         /* HD0000003495329 Added "RAW" */
        m_reason = substring(pcmstr.pc_user1,37,5, "RAW")           /* HD0000003495329 Added "RAW" */
        m_remark = substring(pcmstr.pc_user1,42,50, "RAW")          /* HD0000003495329 Added "RAW" */
/* HD0000002348140 */ m_custduty = decimal(substring(pcmstr.pc_user1,92,14))
        m_netprice  = decimal(substring(pcmstr.pc_user1,106,14)). /* HD0000002525732 */
      end.

      view frame frm1.
      display m_ran m_eono m_champid m_reason m_remark
/* HD0000002348140 */ m_custduty
      m_netprice            /* HD0000002525732 */
      with frame frm1.

      /* Update Ran,EONo. */
      IF ( c-application-mode <> "WEB":U ) THEN DO :
         update m_ran
                m_eono
            with FRAME frm1.
      END. /* c-application-mode <> WEB */
      IF ( c-application-mode = "WEB":U ) THEN DO :
         {us/wb/wbrp06.i &COMMAND = UPDATE &fields = "m_ran m_eono"
          &frm = frm1} /*DJ01*/
      END. /*  c-application-mode = WEB */

      /* UPdate Champion ID */
      IF ( c-application-mode <> "WEB":U ) THEN DO :
         update m_champid
         with FRAME frm1.
      END. /* c-application-mode <> WEB */
      IF ( c-application-mode = "WEB":U ) THEN DO :
         {us/wb/wbrp06.i &COMMAND = UPDATE &fields = "m_champid"
          &frm = frm1}
      END. /*  c-application-mode = WEB */
      /* Display Help from GCM */
      HIDE FRAME frm1.
/* HD0000002348140 {gprun.i ""k1chmhlp.p""} */
/* /* HD0000002348140 */ {gprun.i ""kxchmhlp.p""} MJCR02 */
/* MJCR02 */          {us/bbi/gprun.i ""xxchmhlp_e.p""} /*DJ01*/
      display m_champid with frame frm1.

      /* Update Reason Code */
      IF ( c-application-mode <> "WEB":U ) THEN DO :
         update m_reason
            with FRAME frm1.
      END. /* c-application-mode <> WEB */
      IF ( c-application-mode = "WEB":U ) THEN DO :
         {us/wb/wbrp06.i &COMMAND = UPDATE &fields = "m_reason"
          &frm = frm1} /*DJ01*/
      END. /*  c-application-mode = WEB */

      /* Display Help from GCM */
      HIDE FRAME frm1.
/* HD0000002348140 {gprun.i ""k1rsnhlp.p""} */
/* /* HD0000002348140 */ {gprun.i ""kxrsnhlp.p""} MJCR02 */
/* MJCR02 */          {us/bbi/gprun.i ""xxrsnhlp_e.p""} /*DJ01*/
      display m_reason with frame frm1.

      /* Update Remark and custom duty */
      IF ( c-application-mode <> "WEB":U ) THEN DO :
         update m_remark
/* HD0000002348140 */ m_custduty
         m_netprice       /* HD0000002525732 */
         with FRAME frm1.
      END. /* c-application-mode <> WEB */
      IF ( c-application-mode = "WEB":U ) THEN DO :
         {us/wb/wbrp06.i &COMMAND = UPDATE &fields = "m_remark m_custduty"
          &frm = frm1} /*DJ01*/
      END. /*  c-application-mode = WEB */

      /*U pdate Price List User Field */
      find first pcmstr where pcmstr.pc_domain = global_domain and
                              pcmstr.pc_list = m_list and
                      pcmstr.pc_curr = m_curr and
                  pcmstr.pc_prod_line = m_prod_line and
                  pcmstr.pc_part = m_part and
                  pcmstr.pc_um = m_um and
                  pcmstr.pc_start = m_start exclusive-lock no-error.
      if available pcmstr then do:

         assign pcmstr.pc_user1 = string(m_ran,"x(12)") + string(m_eono,"x(12)") +
                string(m_champid,"x(12)") + string(m_reason,"x(5)") + string(m_remark,"x(50)")  +
/* HD0000002348140 */ string(m_custduty,"->>,>>>,>>9.99")
                + string(m_netprice,"->>,>>>,>>9.99")   .  /* HD0000002525732 */
      end.
      release pcmstr.

      Hide frame frm1.
   end. /* IF FRAME-NAME = "a" AND KEYFUNCTION(LASTKEY) = "GO" */

/*MJ260506 IF FRAME-NAME = "a" AND (KEYFUNCTION(LASTKEY) = "RETURN" or KEYFUNCTION(LASTKEY) = 'TAB') and */

/* MJCR02 START */
   IF FRAME-NAME = "a" and KEYFUNCTION(LASTKEY) = "RETURN" and
      (frame-field = 'pc_start') and m_flag = no then do:
      IF CAN-FIND(FIRST code_mstr WHERE code_domain = global_domain and
                                        code_fldname BEGINS "xxpriceprefix") THEN DO:
         FOR FIRST emp_mstr WHERE emp_domain = global_domain and
                                  emp_addr = global_userid NO-LOCK: END.
         IF AVAILABLE emp_mstr THEN DO:
            FOR FIRST code_mstr WHERE code_domain = global_domain and
                                      code_fldname BEGINS "xxpriceprefix"
                                 /* AND m_list BEGINS code_value  */
                                 AND LOOKUP (emp_title,code_cmmt) > 0
                                 NO-LOCK: END.
            IF NOT AVAILABLE code_mstr THEN DO:
               m_arg1 = " " + getTermLabel("PRICE_LIST",11).
               /* 3920 User does not have access to this # */
               {us/bbi/pxmsg.i &msgnum=3920 &errorlevel=3 &msgarg1=m_arg1} /*DJ01*/
               RETURN NO-APPLY.
            END. /* IF NOT AVAILABLE code_mstr THEN */
            FOR FIRST code_mstr WHERE code_domain = global_domain and
                                      code_fldname BEGINS "xxpriceprefix"
                                 AND m_list BEGINS code_value
                                 /* AND LOOKUP (emp_title,code_cmmt) > 0 */
                                 NO-LOCK: END.
            IF NOT AVAILABLE code_mstr THEN DO:
               m_arg1 = getTermLabel("PRICE_LIST",11) + " " + getTermLabel("PREFIX",7).
               /* 9610 GCM is not defined for # */
               {us/bbi/pxmsg.i &msgnum=9610 &errorlevel=3 &msgarg1=m_arg1} /*DJ01*/
               RETURN NO-APPLY.
            END. /* IF NOT AVAILABLE code_mstr THEN */
            FOR FIRST code_mstr WHERE code_domain = global_domain and
                                      code_fldname BEGINS "xxpriceprefix"
                                 AND m_list BEGINS code_value
                                 AND LOOKUP (emp_title,code_cmmt) > 0
                                 NO-LOCK: END.
            IF NOT AVAILABLE code_mstr THEN DO:
               m_arg1 = " " + getTermLabel("PRICE_LIST",11).
               /* 3920 User does not have access to this # */
               {us/bbi/pxmsg.i &msgnum=3920 &errorlevel=3 &msgarg1=m_arg1}  /*DJ01*/
               RETURN NO-APPLY.
            END. /* IF NOT AVAILABLE code_mstr THEN */

         END. /* IF AVAILABLE emp_mstr THEN */
         ELSE DO:
            m_arg1 = " " + getTermLabel("PRICE_LIST",11).
            /* 3920 User does not have access to this # */
            {us/bbi/pxmsg.i &msgnum=3920 &errorlevel=3 &msgarg1=m_arg1}  /*DJ01*/
            RETURN NO-APPLY.
         END. /* IF NOT AVAILABLE emp_mstr THEN */
      END. /* IF CAN-FIND(FIRST code_mstr */
   END. /* IF FRAME-NAME = "a" and KEYFUNCTION(LASTKEY) = "GO" */
/* MJCR02 END */


/* MJ260506 */ IF FRAME-NAME = "a" AND (KEYFUNCTION(LASTKEY) = "RETURN") and
      (frame-field = 'pc_amt_type') and m_flag = no then do:

      /* To get value to fields */
      RUN GetFieldValue IN THIS-PROCEDURE
      (INPUT "pc_curr", INPUT "a", OUTPUT m_curr).
      RUN GetFieldValue IN THIS-PROCEDURE
      (INPUT "pc_prod_line", INPUT "a", OUTPUT m_prod_line).
       RUN GetFieldValue IN THIS-PROCEDURE
      (INPUT "pc_part", INPUT "a", OUTPUT m_part).
       RUN GetFieldValue IN THIS-PROCEDURE
      (INPUT "pc_um", INPUT "a", OUTPUT m_um).
       RUN GetFieldValue IN THIS-PROCEDURE
      (INPUT "pc_start", INPUT "a", OUTPUT m_start).

      /* Initialise variables */
      find first pcmstr where pcmstr.pc_domain = global_domain and
                              pcmstr.pc_list = m_list and
                      pcmstr.pc_curr = m_curr and
                  pcmstr.pc_prod_line = m_prod_line and
                  pcmstr.pc_part = m_part and
                  pcmstr.pc_um = m_um and
                  pcmstr.pc_start = m_start no-lock no-error.
      if available pcmstr then do:

     assign
        m_ran = substring(pcmstr.pc_user1,1,12, "RAW")        /* HD0000003495329 Added "RAW" */
        m_eono = substring(pcmstr.pc_user1,13,12, "RAW")      /* HD0000003495329 Added "RAW" */
        m_champid = substring(pcmstr.pc_user1,25,12, "RAW")   /* HD0000003495329 Added "RAW" */
        m_reason = substring(pcmstr.pc_user1,37,5, "RAW")     /* HD0000003495329 Added "RAW" */
        m_remark = substring(pcmstr.pc_user1,42,50, "RAW")    /* HD0000003495329 Added "RAW" */
/* HD0000002348140 */ m_custduty = decimal(substring(pcmstr.pc_user1,92,14))
        m_netprice = decimal(substring(pcmstr.pc_user1,106,14))   /* HD0000002525732 */
      .
      end.

      view frame frm1.
      display m_ran m_eono m_champid m_reason m_remark
/* HD0000002348140 */ m_custduty
      m_netprice                /* HD0000002525732 */
      with frame frm1.


      /* Update Ran,EONo. */
      IF ( c-application-mode <> "WEB":U ) THEN DO :
         update m_ran
                m_eono
            with FRAME frm1.
      END. /* c-application-mode <> WEB */
      IF ( c-application-mode = "WEB":U ) THEN DO :
         {us/wb/wbrp06.i &COMMAND = UPDATE &fields = "m_ran m_eono"
          &frm = frm1} /*DJ01*/
      END. /*  c-application-mode = WEB */

      /* UPdate Champion ID */
      IF ( c-application-mode <> "WEB":U ) THEN DO :
         update m_champid
         with FRAME frm1.
      END. /* c-application-mode <> WEB */
      IF ( c-application-mode = "WEB":U ) THEN DO :
         {us/wb/wbrp06.i &COMMAND = UPDATE &fields = "m_champid"
          &frm = frm1} /*DJ01*/
      END. /*  c-application-mode = WEB */

      /* Display Help from GCM */
      HIDE FRAME frm1.
/* HD0000002348140 {gprun.i ""k1chmhlp.p""} */
/* /* HD0000002348140 */ {gprun.i ""kxchmhlp.p""} MJCR02 */
/* MJCR02           {gprun.i ""xxchmhlp_e.p""} */
      display m_champid with frame frm1.


      /* Update Reason Code */
      IF ( c-application-mode <> "WEB":U ) THEN DO :
         update m_reason
            with FRAME frm1.
      END. /* c-application-mode <> WEB */
      IF ( c-application-mode = "WEB":U ) THEN DO :
         {us/wb/wbrp06.i &COMMAND = UPDATE &fields = "m_reason"
          &frm = frm1} /*DJ01*/
      END. /*  c-application-mode = WEB */
      /* Display Help from GCM */
      HIDE FRAME frm1.
/* HD0000002348140 {gprun.i ""k1rsnhlp.p""} */
/* /* HD0000002348140 */ {gprun.i ""kxrsnhlp.p""} MJCR02 */
/* MJCR02           {gprun.i ""xxrsnhlp_e.p""} */
      display m_reason with frame frm1.

      /* Update Remark */
      IF ( c-application-mode <> "WEB":U ) THEN DO :
         update m_remark
/* HD0000002348140 */ m_custduty
         m_netprice                /* HD0000002525732 */
         with FRAME frm1.
      END. /* c-application-mode <> WEB */
      IF ( c-application-mode = "WEB":U ) THEN DO :
         {us/wb/wbrp06.i &COMMAND = UPDATE &fields = "m_remark m_custduty"
          &frm = frm1} /*DJ01*/
      END. /*  c-application-mode = WEB */
      assign m_flag = yes.
      /* Update Price List User Field */
      find first pcmstr where pcmstr.pc_domain = global_domain and
                              pcmstr.pc_list = m_list and
                      pcmstr.pc_curr = m_curr and
                  pcmstr.pc_prod_line = m_prod_line and
                  pcmstr.pc_part = m_part and
                  pcmstr.pc_um = m_um and
                  pcmstr.pc_start = m_start no-error.
      if available pcmstr then do:
         assign pcmstr.pc_user1 = string(m_ran,"x(12)") + string(m_eono,"x(12)") +
                  string(m_champid,"x(12)") + string(m_reason,"x(5)") + string(m_remark,"x(50)") +
/* HD0000002348140 */ string(m_custduty,"->>,>>>,>>9.99")
                    + string(m_netprice,"->>,>>>,>>9.99") . /* HD0000002525732 */
      end.
      release pcmstr.

      Hide frame frm1.

   end. /* IF FRAME-NAME = "a" AND KEYFUNCTION(LASTKEY) = "RETURN" */


/* ****MJ120506 START**** */
   IF FRAME-NAME = "b" and KEYFUNCTION(LASTKEY) = "GO" then do:
      assign m_flag = no.
   end.
   IF FRAME-NAME = "b" and (KEYFUNCTION(LASTKEY) = "RETURN" or KEYFUNCTION(LASTKEY) = 'TAB') and
      (frame-field = 'pc_amt') then do:
      assign m_flag = no.
   end.
/* ****MJ120506 END**** */

END. /* ON GO,enter */

{us/wb/wbrp04.i} /*DJ01*/
/* Price List Maintenance */
/*
{us/bbi/gprun.i ""ppvnpcmt.p""} /*DJ01*/
*/
{us/bbi/gprun.i ""popomt.p""}
PROCEDURE GetFrame:
DEFINE INPUT PARAMETER piHandle    AS HANDLE NO-UNDO.
DEFINE INPUT PARAMETER piFrameName AS CHAR   NO-UNDO.
DEFINE OUTPUT PARAMETER poHandle   AS HANDLE NO-UNDO.

DEFINE VARIABLE hChild AS HANDLE NO-UNDO.

IF VALID-HANDLE(piHandle) THEN
DO:
  ASSIGN hChild = piHandle:FIRST-CHILD.
  REPEAT WHILE(VALID-HANDLE(hChild)):
    IF hChild:TYPE = "FRAME" AND hChild:NAME = piFrameName THEN
    DO:
      ASSIGN poHandle = hChild.
      LEAVE.
    END.
    ELSE hChild = hChild:NEXT-SIBLING.
  END.
END.
RETURN "".
END PROCEDURE.


PROCEDURE GetFieldValue:
DEFINE INPUT PARAMETER piFieldName   AS CHAR NO-UNDO.
DEFINE INPUT PARAMETER piFrameName   AS CHAR NO-UNDO.
DEFINE OUTPUT PARAMETER poFieldValue AS CHAR NO-UNDO.

 DEFINE VARIABLE hparent     AS HANDLE     NO-UNDO.
 DEFINE VARIABLE hfldgrp     AS HANDLE     NO-UNDO.
 DEFINE VARIABLE hfield      AS HANDLE     NO-UNDO.


ASSIGN hparent = GetTopParent (SELF).
IF VALID-HANDLE(hparent) THEN
DO:
  RUN GetFrame IN THIS-PROCEDURE
    (INPUT hparent, INPUT piFrameName, OUTPUT hfield).
  IF VALID-HANDLE(hfield) THEN
  DO:
    ASSIGN hfield = hfield:FIRST-CHILD.
    IF hfield:TYPE = "FIELD-GROUP" THEN
    DO:
      ASSIGN hfldgrp = hfield.
      fldgrp:
      REPEAT WHILE(VALID-HANDLE(hfldgrp)):
        ASSIGN hfield = hfldgrp:FIRST-CHILD.
        fld:
        REPEAT WHILE(VALID-HANDLE(hfield)):
                IF hfield:NAME = piFieldName THEN
                DO:
                  ASSIGN poFieldValue = hfield:SCREEN-VALUE.
                  LEAVE fldgrp.
            END.  /* END IF hfield:NAME = "pod_reason" THEN */
            ELSE hfield = hfield:NEXT-SIBLING.
        END. /* END REPEAT WHILE(VALID-HANDLE(hfldgrp)): */
        ASSIGN hfldgrp = hfldgrp:NEXT-SIBLING.
      END.  /* END REPEAT WHILE(VALID-HANDLE(hfldgrp)):*/
    END.  /* END IF hfield:TYPE = "FIELD-GROUP" THEN */
    ELSE
    DO:
      REPEAT WHILE(VALID-HANDLE(hfield)):
        IF hfield:NAME = piFieldName THEN
        DO:
          ASSIGN poFieldValue = hfield:SCREEN-VALUE.
          LEAVE.
        END.   /* END IF hfield:NAME = "pod_reason" THEN */
        ELSE hfield = hfield:NEXT-SIBLING.
      END.  /* END REPEAT WHILE(VALID-HANDLE(hfield)): */
    END.   /* END ELSE IF hfield:TYPE = "FIELD-GROUP" THEN */
  END.  /* END IF VALID-HANDLE(hfield) THEN */
  ELSE RETURN "Not a valid frame".
END.  /* END IF VALID-HANDLE(hparent) THEN  */
ELSE RETURN "Not a valid handle".
RETURN "".
END PROCEDURE.

PROCEDURE SetFieldValue:
DEFINE INPUT PARAMETER piFieldName    AS CHAR NO-UNDO.
DEFINE INPUT PARAMETER piFrameName    AS CHAR NO-UNDO.
DEFINE INPUT PARAMETER piFieldValue   AS CHAR NO-UNDO.
DEFINE OUTPUT PARAMETER poResult      AS LOG  NO-UNDO.

DEFINE VARIABLE hparent     AS HANDLE     NO-UNDO.
DEFINE VARIABLE hfldgrp     AS HANDLE     NO-UNDO.
DEFINE VARIABLE hfield      AS HANDLE     NO-UNDO.

ASSIGN hparent  = GetTopParent (SELF)
       poResult = NO.
IF VALID-HANDLE(hparent) THEN
DO:
  RUN GetFrame IN THIS-PROCEDURE
    (INPUT hparent, INPUT piFrameName, OUTPUT hfield).

  IF VALID-HANDLE(hfield) THEN
  DO:
    ASSIGN hfield = hfield:FIRST-CHILD.
    IF hfield:TYPE = "FIELD-GROUP" THEN
    DO:
      ASSIGN hfldgrp = hfield.
      fldgrp:
      REPEAT WHILE(VALID-HANDLE(hfldgrp)):
        ASSIGN hfield = hfldgrp:FIRST-CHILD.
        fld:
        REPEAT WHILE(VALID-HANDLE(hfield)):
                IF hfield:NAME = piFieldName THEN
                DO:
                  ASSIGN hfield:SCREEN-VALUE = piFieldValue
                         poResult = YES.
                  LEAVE fldgrp.
            END.  /* END IF hfield:NAME = "pod_reason" THEN */
            ELSE hfield = hfield:NEXT-SIBLING.
        END. /* END REPEAT WHILE(VALID-HANDLE(hfldgrp)): */
        ASSIGN hfldgrp = hfldgrp:NEXT-SIBLING.
      END.  /* END REPEAT WHILE(VALID-HANDLE(hfldgrp)):*/
    END.  /* END IF hfield:TYPE = "FIELD-GROUP" THEN */
    ELSE
    DO:
      REPEAT WHILE(VALID-HANDLE(hfield)):
        IF hfield:NAME = piFieldName THEN
        DO:
          ASSIGN hfield:SCREEN-VALUE = piFieldValue
                 poResult = YES.
          LEAVE.
        END.   /* END IF hfield:NAME = "pod_reason" THEN */
        ELSE hfield = hfield:NEXT-SIBLING.
      END.  /* END REPEAT WHILE(VALID-HANDLE(hfield)): */
    END.   /* END ELSE IF hfield:TYPE = "FIELD-GROUP" THEN */
  END.  /* END IF VALID-HANDLE(hfield) THEN */
  ELSE RETURN "Not a valid frame".
END.  /* END IF VALID-HANDLE(hparent) THEN  */
ELSE RETURN "Not a valid handle".
RETURN "".
END PROCEDURE.
